package net.huashitong.synthetical.question.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import net.huashitong.synthetical.question.entity.Coordinate;
import net.huashitong.synthetical.question.filter.CoordinateFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class CoordinateDao extends StringDao<Coordinate> {
    public List<Coordinate> queryAllCoordinate(CoordinateFilter filter){
        GenericQuery query = createQuery("obj");
        //查询所有问题
        return query.listResult(filter);
    }
    public List<Coordinate> queryCoordinate(CoordinateFilter filter){
        GenericQuery query = createQuery("obj");
        if (filter.getBaseInfo()!=null&&!"".equals(filter.getBaseInfo()))
            query.append(" and baseInfo like:baseInfo").setParam("baseInfo","%" + filter.getBaseInfo() + "%");
        if (filter.getProjectName()!=null&&!"".equals(filter.getProjectName()))
            query.append(" and projectName like:projectName").setParam("projectName","%" + filter.getProjectName() + "%");
        if (filter.getContact()!=null&&!"".equals(filter.getContact()))
            query.append(" and contact =:contact").setParam("contact",filter.getContact());
        if (filter.getFenguanLeader()!=null&&!"".equals(filter.getFenguanLeader()))
            query.append(" and fenguanLeader =:fenguanLeader").setParam("fenguanLeader",filter.getFenguanLeader());
        if (filter.getHelpInfo()!=null&&!"".equals(filter.getHelpInfo()))
            query.append(" and helpInfo like:helpInfo").setParam("helpInfo","%" + filter.getHelpInfo() + "%");
        if (filter.getInvolveUnit()!=null&&!"".equals(filter.getInvolveUnit()))
            query.append(" and involveUnit =:involveUnit").setParam("involveUnit",filter.getInvolveUnit());
        if (filter.getResDept()!=null&&!"".equals(filter.getResDept()))
            query.append(" and resDept =:resDept").setParam("resDept",filter.getResDept());
        if (filter.getSysId()!=null&&!"".equals(filter.getSysId()))
            query.append(" and sysId =:sysId").setParam("sysId",filter.getSysId());
        if (filter.getSource()!=null&&!"".equals(filter.getSource()))
            query.append(" and source =:source").setParam("source",filter.getSource());
        query.append(" and obj.aaa001='1'");
        return query.listResult(filter);
    }



}
